const EventEmitter =require ('events').EvenEmitter;
const {EventEmitter}=require('events');

class Dog extends EventEmitter{

  constructor(name.age){
    super();
    this.#name=name;
    this.#energy=energy;
    this.#startTimer();
  }
  get name(){
    return this.#name;
  }
  get energy(){
    return this.#energy;
  }
  set energy(e){
    this.energy=e
    this.#startTimer();
  }

#startTimer(){
  if(this.#timer!==null) return;
  this.#timer=setInterval(()=>{
    if(this.#energy>0){

      this.#enegy--;
      this.emit('bark');
    }else{
      clearInterval(this.#timer)
    ;
      this.#timer=null;
    }
  },1000);

}
  #name='';
  #enegry=0;
  #timer=null;
}

module.exports=Dog;

